package com.gitee.qdbp.general.trade.api.order.main.model;

import java.util.Date;
import com.gitee.qdbp.base.annotation.DataIsolation;
import com.gitee.qdbp.base.annotation.OperateTraces;
import com.gitee.qdbp.base.enums.DataState;
import com.gitee.qdbp.general.trade.enums.OrderType;

/**
 * 订单明细实体类
 *
 * @author zhh
 * @version 180626
 */
@OperateTraces(id = "id")
@DataIsolation("tenantCode")
public class OrderItemBean extends OrderItemBase {

    /** 版本序列号 **/
    private static final long serialVersionUID = 1L;

    /** 表名 **/
    public static final String TABLE = "vml_order_item";

    /** 主键 **/
    private String id;

    /** 商家租户编号 **/
    private String tenantCode;

    /** 消费者用户ID **/
    private String userId;

    /** 订单ID **/
    private String orderId;

    /** 订单类型(0.捐款订单|1.商品订单) **/
    private OrderType orderType;

    /** 关联业务ID **/
    private String dataId;

    /** 创建时间 **/
    private Date createTime;

    /** 选项 **/
    private OrderItemOptions options;

    /** 数据状态:0为正常|其他为删除 **/
    private DataState dataState;

    /** 获取主键 **/
    public String getId() {
        return id;
    }

    /** 设置主键 **/
    public void setId(String id) {
        this.id = id;
    }

    /** 获取商家租户编号 **/
    public String getTenantCode() {
        return tenantCode;
    }

    /** 设置商家租户编号 **/
    public void setTenantCode(String tenantCode) {
        this.tenantCode = tenantCode;
    }

    /** 获取消费者用户ID **/
    public String getUserId() {
        return userId;
    }

    /** 设置消费者用户ID **/
    public void setUserId(String userId) {
        this.userId = userId;
    }

    /** 获取订单ID **/
    public String getOrderId() {
        return orderId;
    }

    /** 设置订单ID **/
    public void setOrderId(String orderId) {
        this.orderId = orderId;
    }

    /** 获取订单类型(0.捐款订单|1.商品订单) **/
    public OrderType getOrderType() {
        return orderType;
    }

    /** 设置订单类型(0.捐款订单|1.商品订单) **/
    public void setOrderType(OrderType orderType) {
        this.orderType = orderType;
    }

    /** 获取关联业务ID **/
    public String getDataId() {
        return dataId;
    }

    /** 设置关联业务ID **/
    public void setDataId(String dataId) {
        this.dataId = dataId;
    }

    /** 获取创建时间 **/
    public Date getCreateTime() {
        return createTime;
    }

    /** 设置创建时间 **/
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    /** 获取选项 **/
    public OrderItemOptions getOptions() {
        return options;
    }

    /** 获取选项, force=是否强制返回非空对象 **/
    public OrderItemOptions getOptions(boolean force) {
        if (options == null && force) {
            options = new OrderItemOptions();
        }
        return options;
    }

    /** 设置选项 **/
    public void setOptions(OrderItemOptions options) {
        this.options = options;
    }

    /** 获取数据状态:0为正常|其他为删除 **/
    public DataState getDataState() {
        return dataState;
    }

    /** 设置数据状态:0为正常|其他为删除 **/
    public void setDataState(DataState dataState) {
        this.dataState = dataState;
    }

    /**
     * 将当前对象转换为子类对象
     *
     * @param clazz 目标类型
     * @return 目标对象
     */
    public <T extends OrderItemBase> T to(Class<T> clazz) {
        T instance = super.to(clazz);

        if (instance instanceof OrderItemBean) {
            OrderItemBean real = (OrderItemBean) instance;
            real.setId(this.getId()); // 主键
            real.setTenantCode(this.getTenantCode()); // 商家租户编号
            real.setUserId(this.getUserId()); // 消费者用户ID
            real.setOrderId(this.getOrderId()); // 订单ID
            real.setOrderType(this.getOrderType()); // 订单类型(0.捐款订单|1.商品订单)
            real.setDataId(this.getDataId()); // 关联业务ID
            real.setCreateTime(this.getCreateTime()); // 创建时间
            real.setOptions(this.getOptions()); // 选项
            real.setDataState(this.getDataState()); // 数据状态:0为正常|其他为删除
        }
        return instance;
    }

}
